package com.jzo2o.orders.manager.listener;

import com.jzo2o.common.constants.MqConstants;
import com.jzo2o.orders.manager.service.IOrdersManagerService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @Description: 支付成功监听器
 * @Author: itcast
 * @Date: 2023/10/17 10:05
 * @Version: V1.0
 */
@Component
@Slf4j
public class PaySuccessListener {

    @Resource
    private IOrdersManagerService managerService;

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(value = MqConstants.Queues.ORDERS_TRADE_UPDATE_STATUS, durable = "true"),
            exchange = @Exchange(value = MqConstants.Exchanges.TRADE),
            key = MqConstants.RoutingKeys.TRADE_UPDATE_STATUS
    ))
    public void paySuccess(String transactionInfo) {
        log.info("支付成功监听{}", transactionInfo);
        //调用支付成功接口
        managerService.paySuccess(transactionInfo);
    }
}
